<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>查找最大值最小值</title>
	</head>
	<body>
		<script>
			var array=[100,45,3,67,20];
			//保存最大值和最小值
			var max=array[0];
			var min=array[0];
			//循环
			for (var i in array){
				//判断当前元素与max,min
				if(array[i]>max){
					max=array[i];
				}
				if(array[i]<min){
					min=array[i];
				}
			}
			console.log("数组："+array);
			
			console.log("最大值:"+max);
			console.log("最小值:"+min);
		</script>
	</body>
</html>
